import { use3DEditorStore } from '@/store'
import { storeToRefs } from 'pinia'
import * as THREE from 'three'
import { TransformControls } from 'three/examples/jsm/Addons'

export default () => {
  const editorStore = use3DEditorStore()
  const { handleElement } = storeToRefs(editorStore)
  const keyboardKey = shallowRef('')
  const isTransform = shallowRef(false)
  const mesh = shallowRef<THREE.Object3D>(null)

  const onKeyDown = (e: KeyboardEvent) => {
    if (!mesh.value) return
    switch (e.key) {
      case 'g':
        break
      case 'r':
        // rotation.value.copy(mesh.value.rotation)
        break
      case 'Escape':
        break
      default:
        break
    }
  }

  const onPointerDown = (e: PointerEvent) => {
    if (!mesh.value) return
    isTransform.value = false
  }

  return { keyboardKey, onKeyDown, isTransform, onPointerDown, mesh }
}
